package com.aoxin.service.impl.opm;

import com.aoxin.mapper.SlfRechargeMapper;
import com.aoxin.model.SlfRecharge;
import com.aoxin.service.inter.opm.RechargeService;
import com.aoxin.util.ErrorUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.List;

@Service("RechargeServiceImpl")
public class RechargeServiceImpl implements RechargeService {


    @Autowired
    private SlfRechargeMapper slfRechargeMapper;

    @Override
    public List<SlfRecharge> getSlfRecharge(SlfRecharge slfRecharge) {
        Assert.notNull(slfRecharge, String.format(ErrorUtil.PARAMETER_NULL, "slfRecharge"));
		List<SlfRecharge> list = slfRechargeMapper.getSlfRecharge(slfRecharge);
        return list;
    }

    @Override
    public Integer updateSlfRecharge(SlfRecharge slfRecharge) {
        Assert.notNull(slfRecharge, String.format(ErrorUtil.PARAMETER_NULL, "slfRecharge"));
        if (slfRecharge !=null){
            slfRechargeMapper.updateSlfRecharge(slfRecharge);
        }
        return slfRecharge.getRecharge();
    }

    @Override
    public Integer deleteRecharge(List<Integer> recharges) {
        Assert.notNull(recharges, String.format(ErrorUtil.PARAMETER_NULL, "recharges"));
        if (recharges !=null){
            slfRechargeMapper.deleteRecharge(recharges);
        }
        return 1;
    }

    @Override
    public Integer insertSlfRecharge(SlfRecharge slfRecharge) {
        Assert.notNull(slfRecharge, String.format(ErrorUtil.PARAMETER_NULL, "slfRecharge"));
        Integer recharge = 0;
        if (slfRecharge !=null){
            recharge = slfRechargeMapper.insertSlfRecharge(slfRecharge);
        }
        return recharge;
    }

    @Override
    public Integer deleteSlfRecharge(Integer recharge) {
        Assert.notNull(recharge, String.format(ErrorUtil.PARAMETER_NULL, "recharge"));
        if (recharge !=null){
            slfRechargeMapper.deleteSlfRecharge(recharge);
        }
        return 1;
    }
}
